package cn.tedu.basic;
/*本类用作类型转换测试*/
public class TestTypeChange {
    public static void main(String[] args) {
        byte a = 10;
        short b = a;//不会报错,小转大

        int c = 1;
        long d = c;//不会报错,小转大

        float f = 3.1415f;
        double e = f;//不会报错,小转大

        long g = 545659655656L;
        float h = g;//不会报错,小转大

        char i = 'a';
        int j = i;//不会报错,小转大

        int a1 = 1;
        byte b1 = 2;
        //byte c1 = a1 + b1;
        byte c1 = (byte)(a1 + b1);

        byte d1 = (byte)128;
        System.out.println(d1);//-128

        short e1 = 'a';
        char f1 = 5647;
        System.out.println(f1);//打印的是编码值
        System.out.println(e1);//打印的是根据编码值找到的字符

        float h1 = 354765.567f;
        int i1 = (int)h1;//大转小,强制转
        System.out.println(i1);//浮变整,小数没

    }
}
